#ifndef SRC_WRAPPERS_NVTX_W_NVTX_H_
#define SRC_WRAPPERS_NVTX_W_NVTX_H_

// namespace espreso {
// namespace nvtx {

// The wrapper should be resolved correctly - no CUDA dependency
// NVTX v3 should support header-only implementation - no library linking required

// NVTX library (CUDA profiling tags)
#ifdef USE_NVTX
    #include "nvToolsExt.h"

    const uint32_t colors[] = { 0xff00ff00, 0xff0000ff, 0xffffff00, 0xffff00ff, 0xff00ffff, 0xffff0000, 0xffffffff };
    const int num_colors = sizeof(colors) / sizeof(uint32_t);
    // extern const uint32_t colors[7];
    // extern const int num_colors;
    typedef enum { GREEN, BLUE, YELLOW, PURPLE, TURQUOISE, RED, GREY } color_names;

    #define PUSH_RANGE(name, cid)                              \
        {                                                      \
            int color_id = cid;                                \
            color_id = color_id % num_colors;                  \
            nvtxEventAttributes_t eventAttrib = {0};           \
            eventAttrib.version = NVTX_VERSION;                \
            eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;  \
            eventAttrib.colorType = NVTX_COLOR_ARGB;           \
            eventAttrib.color = colors[color_id];              \
            eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII; \
            eventAttrib.message.ascii = name;                  \
            nvtxRangePushEx(&eventAttrib);                     \
        }
    #define POP_RANGE nvtxRangePop();
#else
    #define PUSH_RANGE(name, cid)
    #define POP_RANGE
#endif

// }
// }

#endif /* SRC_WRAPPERS_NVTX_W_NVTX_H_ */